package com.zgyd.tools;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
//import com.itheima.ai.entity.po.Course;
//import com.itheima.ai.entity.po.CourseReservation;
//import com.itheima.ai.entity.po.School;
//import com.itheima.ai.entity.query.CourseQuery;
//import com.itheima.ai.service.ICourseReservationService;
//import com.itheima.ai.service.ICourseService;
//import com.itheima.ai.service.ISchoolService;
import com.zgyd.domin.query.CourseQuery;
import com.zgyd.entity.po.Packages;
import com.zgyd.service.IPackagesService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
public class CourseTools {

    @Autowired
    private  IPackagesService packagesService;


    @Tool(description = "根据条件查询套餐")
    public List<Packages> queryPackages(@ToolParam(required = false, description = "套餐查询条件") CourseQuery query) {
        if(query==null){
            return packagesService.list();
        }
        QueryWrapper<Packages> qw = new QueryWrapper<>();
        qw.le(query.getMonthly_rent()!=null,"monthly_rent",query.getMonthly_rent());
        qw.le(query.getTraffic()!=null,"traffic",query.getTraffic());
//        if(CollUtil.isNotEmpty(query.getSorts())){
//            for (CourseQuery.Sort sort : query.getSorts()) {
//                qw.orderBy(true,sort.getIsAsc(),sort.getField());
//            }
//        }
        return packagesService.list(qw);
    }

//    @Tool(description = "查询所有校区")
//    public List<School> queryAllSchools() {
//        return schoolService.list();
//    }
//
//    @Tool(description = "生成课程预约单,并返回生成的预约单号")
//    public String generateCourseReservation(
//            String courseName, String studentName, String contactInfo, String school, String remark) {
//        CourseReservation courseReservation = new CourseReservation();
//        courseReservation.setCourse(courseName);
//        courseReservation.setStudentName(studentName);
//        courseReservation.setContactInfo(contactInfo);
//        courseReservation.setSchool(school);
//        courseReservation.setRemark(remark);
//        courseReservationService.save(courseReservation);
//        return String.valueOf(courseReservation.getId());
//    }
}